import { lazy } from 'react';
import {
    createBrowserRouter
  } from "react-router-dom";
const reqRouter = require.context('../views', true, /\.page.tsx$/, 'lazy');
const pages:any[] = [];
reqRouter.keys().forEach(async (element:string) => {
    const arr = element.split('/');
    const texts = arr[arr.length - 1];
    const fileName = texts.replace('.page.tsx', '');
    let url = `/${fileName.replace(/\./ig, '/')}`;
    
    pages.push({
        path: url,
        Component: lazy(() =>{
          return import(`../views${element.substring(1)}`)
      })
    });

});


export default createBrowserRouter(pages)